package com.sofwin.controller;

import com.sofwin.Log;
import com.sofwin.base.ResponseEntity;
import com.sofwin.pojo.SysMenu;
import com.sofwin.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.awt.*;
import java.util.List;

/**
 * @packageName: com.sofwin.controller
 * @author: andyliu
 * @date: 2022/8/15 14:29
 * @email 115176513@qq.com
 * @description: TODO
 */
@Controller
@RequestMapping("/menu")
public class MenuController {
@Autowired
private MenuService menuService;
  @ResponseBody
  @GetMapping()
  @Log(module = "菜单查询",operatorType = 1)
    public ResponseEntity test01(SysMenu menu){
        List<SysMenu> menus = menuService.queryMenus(menu);
        return ResponseEntity.success(menus);
    }

    @GetMapping("toList")
    public String toList(){
      return "menu/list";
    }

    @GetMapping("toEdit")
    public String toEdit(){
      return  "menu/edit";

    }

    @GetMapping("toZTree")
  public  String  toZTree(){
    return  "menu/ztree";
    }

    @PostMapping("/save")
    @ResponseBody
    public  ResponseEntity save(SysMenu menu){
      boolean b = menuService.saveMenu(menu);
      if (b){
       return ResponseEntity.success();
      }else {
       return   ResponseEntity.error();
      }
    }
}
